﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using System.Collections;
namespace LibraryManagement.ThongKeSach
{
    public partial class ThongKeSach : DevExpress.XtraEditors.XtraUserControl
    {
        ThongKeSach_Info tks_info;
        ThongKeSach_CTL tks_ctl;

        public static DataTable dtb;

        private int chonthang;

        public int Chonthang
        {
            get { return chonthang; }
            set { chonthang = value; }
        }
        public ThongKeSach()
        {
            InitializeComponent();
            dtb  = new DataTable();
            tks_info = new ThongKeSach_Info();
            tks_ctl = new ThongKeSach_CTL();
            tks_info.Nam = tks_ctl.LoadNam();
            comboBoxEdit2.Enabled = false;
            for (int i = 0; i < tks_info.Nam.Properties.Items.Count; i++)
                comboBoxEdit2.Properties.Items.Add(tks_info.Nam.Properties.Items[i]);
        }
        private void comboBoxEdit1_SelectedIndexChanged(object sender, EventArgs e)
        {
            comboBoxEdit2.Properties.Items.Clear();
            tks_info.Nam = tks_ctl.LoadNamTheoThang(int.Parse(comboBoxEdit1.SelectedText));
            for (int i = 0; i < tks_info.Nam.Properties.Items.Count; i++)
                comboBoxEdit2.Properties.Items.Add(tks_info.Nam.Properties.Items[i]);
            comboBoxEdit2.SelectedIndex = -1;
            comboBoxEdit2.Enabled = true;
        }

        private void simpleButton1_Click(object sender, EventArgs e)
        {
            tks_info.Dt = tks_ctl.LoadThongKe(int.Parse(comboBoxEdit1.SelectedText), int.Parse(comboBoxEdit2.SelectedText));
            dataGridView1.DataSource = tks_info.Dt;

            
            
        }

        private void simpleButton2_Click(object sender, EventArgs e)
        {
            dtb = tks_info.Dt;
            FormTKSach fsach = new FormTKSach();

            fsach.ShowDialog();

            
           
            
        }


    }
}
